package ru.ncedu.java.vlku.hrs.uil.cmd;

import ru.ncedu.java.vlku.hrs.bll.HRSManager;
import ru.ncedu.java.vlku.hrs.bll.HRSManagerFactory;
import ru.ncedu.java.vlku.hrs.model.Tariff;

public class UpdateTariff implements Command {
    // update tariff <id> <name>
    @Override
    public void execute(String[] args) {
        if (args.length != 4)
            throw new IllegalArgumentException();
        HRSManager manager = HRSManagerFactory.getInstance().getHRSManager();
        Long id = Long.parseLong(args[2]);
        Tariff tariff = manager.getTariffById(id);
        tariff.setName(args[3]);
        manager.updateTariff(tariff);
    }
}
